﻿Imports BE.BE

Namespace DAL

    Public Class DAL_Asegurador

        Shared Sub altaAsegurador(pAsegurador As Asegurador_BE)

            Try

                pAsegurador.Id = Helper_DAL.ObtenerProximoId("asegurador")
            Catch ex As Exception
                Throw ex
            End Try

            Dim strcomm As String = "insert into asegurador (id_asegurador, cuit, razon_social) values " & _
                "(" & pAsegurador.Id & ",'" & pAsegurador.CUIT & "','" & pAsegurador.RazonSocial & "')"

            Try
                Helper_DAL.ExecuteNonQuery(strcomm)

            Catch ex As Exception
                Throw ex
            End Try

        End Sub

        Shared Function listarAsegurador() As List(Of Asegurador_BE)
            Dim strcomm As String = "select id_asegurador, cuit, razon_social from asegurador"
            Dim mLista As New List(Of Asegurador_BE)
            Dim mDs As New DataSet
            Try
                mDs = Helper_DAL.ExecuteDataset(strcomm)

                If mDs.Tables(0).Rows.Count > 0 Then
                    For Each dr As DataRow In mDs.Tables(0).Rows
                        Dim mAseg As New Asegurador_BE

                        mAseg.Id = dr.Item(0)
                        mAseg.CUIT = dr.Item(1).ToString
                        mAseg.RazonSocial = dr.Item(2).ToString



                        mLista.Add(mAseg)
                    Next
                End If
                Return mLista
            Catch ex As Exception
                Throw ex
            End Try


        End Function
    End Class
End Namespace